<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>课程管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function checkValidate()
		{
			var courseName=document.getElementById("courseName").value;
			var courseAttribute=document.getElementById("courseAttribute").value;
			var duallist=document.getElementById("duallist").value;
			//判断是否为空
			if(courseName==""||courseName==null)
			{
				window.alertx("请输入课程名称！");
				return false;
			}
			if(courseAttribute==""||courseAttribute==null)
			{
				window.alertx("请选择课程属性！");
				return false;
			}
			if(duallist==""||duallist==null)
			{
				window.alertx("请选择课件！");
				return false;
			}
		}
		function selectAttribute(attribute){
			$.ajax({
				type: "POST",
				url: "${ctx}/resource/resourceCourse/findCoursewareListByAttribute",
				data: {
					attribute:attribute.options[attribute.selectedIndex].value
				},
				success:function(json){
					document.getElementById("example").value="somethind";
				},
				error:function(){
					alertx("error");
				}
			});
		}
	</script>

	<script type="text/javascript" src="${path}/js/common/jquery.min.js"></script>
	<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all">
	<%--<link rel="stylesheet" href="${path}/css/common/bootstrap.min.css" rel="stylesheet" type="text/css" media="all"/>--%>
	<link rel="stylesheet" href="${path}/css/common/bootstrap-duallistbox.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="${path}/js/common/jquery.bootstrap-duallistbox.js"></script>

	<style>
		.control-label{font-weight: normal;}
		#courseName{ height: 30px;}
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/resource/resourceCourse/">课程列表</a></li>
		<li class="active"><a href="${ctx}/resource/resourceCourse/form?id=${resourceCourse.id}">课程<c:choose><c:when test="${not empty type}">复制</c:when><c:otherwise><shiro:hasPermission name="resource:resourceCourse:edit">${not empty resourceCourse.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="resource:resourceCourse:edit">查看</shiro:lacksPermission></c:otherwise></c:choose></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="resourceCourse" action="${ctx}/resource/resourceCourse/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" name="type" id="type" value="${type}">
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">课程名称：</label>
			<div class="controls">
				<form:input name="courseName" path="courseName"  htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">课程属性：</label>
			<div class="controls">
				<%--<select id="courseAttribute" name="courseAttribute" class="input-xlarge required" onfocus="<c:if test="${isSuperAdmin=='false'}">this.defaultIndex=this.selectedIndex;</c:if>" onchange="<c:if test="${isSuperAdmin=='false'}">this.selectedIndex=this.defaultIndex;</c:if>" readOnly="<c:if test="${isSuperAdmin=='false'}">true</c:if>">--%>
				<select id="courseAttribute" name="courseAttribute" class="input-xlarge required">


					<c:choose>
						<c:when test="${isSuperAdmin=='false'}">
							<option value="0" selected>${fns:getDictLabel("0",'resource_course_attribute',"无")}</option>
						</c:when>
						<c:otherwise>
							<c:forEach var="attribute" items="${fns:getDictList('resource_course_attribute')}">
								<option value="${fns:getDictValue(attribute,'resource_course_attribute',"")}" <c:if test="${fns:getDictValue(attribute,'resource_course_attribute','')==resourceCourse.courseAttribute}">selected</c:if>>${attribute}</option>
							</c:forEach>
						</c:otherwise>
					</c:choose>


				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">选择课件：</label>
			<div class="controls">
				<div class="container"></div>
					<%--<%@ include file="maskProgramFormTest.jsp"%>--%>
				<div class="col-lg-10 col-md-9 col-sm-9 col-xs-12">

					<select  multiple="multiple" size="10" id="duallist" name="duallist" class="resetDuallist">


						<c:forEach var="resourceCourseware" items="${resourceCoursewareList}">
							<option value="${resourceCourseware.id}" <c:if test="${resourceCourseware.isChoose=='true'}">selected</c:if>>${resourceCourseware.coursewareName}</option>
						</c:forEach>


							<%--<option value="option1">Option 1</option>--%>
							<%--<option value="option2">Option 2</option>--%>
							<%--<option value="option3" selected="selected">Option 3</option>--%>
							<%--<option value="option4">Option 4</option>--%>
							<%--<option value="option5">Option 5</option>--%>
							<%--<option value="option6" selected="selected">Option 6</option>--%>
							<%--<option value="option7">Option 7</option>--%>
							<%--<option value="option8">Option 8</option>--%>
							<%--<option value="option9">Option 9</option>--%>
							<%--<option value="option0">Option 10</option>--%>
							<%--<option value="option8">Option 8</option>--%>
							<%--<option value="option9">Option 9</option>--%>
							<%--<option value="option0">Option 10</option>--%>

					</select>



				</div>
				<span class="help-inline" ><font color="red">*</font> </span>


			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="resource:resourceCourse:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" onclick=" return checkValidate()"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<script>
		var demo1 = $('select[class="resetDuallist"]').bootstrapDualListbox();
		$("#demoform").submit(function() {
			alert($('[class="resetDuallist"]').val());
			return false;
		});
	</script>
</body>
</html>